<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>全选</title>
</head>
<body>
<input class="button" type="checkbox">全选
<ul>
    <li><input type="checkbox">杜比环绕</li>
    <li><input type="checkbox">精品热卖</li>
    <li><input type="checkbox">华为</li>
    <li><input type="checkbox">小米</li>
    <li><input type="checkbox">荣耀</li>
</ul>
    <script>
        let button = document.getElementsByClassName("button")[0]
        let inputArr = document.getElementsByTagName("ul")[0].getElementsByTagName("input")
         button.onclick = function (){
            let bool = button.checked;
            for(let i= 0; i<inputArr.length; i++){
                inputArr[i].checked = bool;
            }
         }
    </script>

</body>
</html>
